package net.schmurgon.gwt.scaffold.generated;

import com.google.gwt.app.place.AbstractRecordListView;
import com.google.gwt.app.place.PropertyColumn;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.DateTimeFormatRenderer;
import com.google.gwt.text.shared.AbstractRenderer;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTMLPanel;
import net.schmurgon.gwt.request.RunRecord;
import net.schmurgon.gwt.shared.CourseType;
import net.schmurgon.gwt.request.RunnerRecord;

import java.util.ArrayList;
import java.util.List;

/**
 * {@link AbstractRecordListView} specialized to {@link RunKey}} values.
 */
public class RunListView extends AbstractRecordListView<RunRecord> {
	interface Binder extends UiBinder<HTMLPanel, RunListView> {
	}

	private static final Binder BINDER = GWT.create(Binder.class);

	@UiField CellTable<RunRecord> table;
	@UiField Button newButton;
  
	public RunListView() {
		init(BINDER.createAndBindUi(this), table, newButton, getColumns());
	}

	protected List<PropertyColumn<RunRecord, ?>> getColumns() {
		// TODO These should be <g:col> elements in a <g:table> in the ui.xml file

		List<PropertyColumn<RunRecord, ?>> columns = new ArrayList<PropertyColumn<RunRecord, ?>>();
		
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.bonus, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, net.schmurgon.gwt.shared.CourseType>(RunRecord.courseType, new AbstractRenderer<net.schmurgon.gwt.shared.CourseType>() {
      public String render(net.schmurgon.gwt.shared.CourseType obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.finishMinutes, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.finishSeconds, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.handicapMinutes, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.handicapSeconds, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, net.schmurgon.gwt.request.RunnerRecord>(RunRecord.runner, net.schmurgon.gwt.scaffold.generated.RunnerRecordRenderer.instance()));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.score, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.startMinutes, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));
	    columns.add(new PropertyColumn<RunRecord, java.lang.Integer>(RunRecord.startSeconds, new AbstractRenderer<java.lang.Integer>() {
      public String render(java.lang.Integer obj) {
        return obj == null ? "" : String.valueOf(obj);
      }    
}));		
	    return columns;
	}
}
